
package com.xpo.settingskeeper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

public class SettingsDBHelper extends SQLiteOpenHelper {

    private static final String CREATE_TABLE_TEMPLATE = " (" + android.provider.BaseColumns._ID
            + " INTEGER PRIMARY KEY AUTOINCREMENT," + android.provider.Settings.NameValueTable.NAME
            + " TEXT," + android.provider.Settings.NameValueTable.VALUE + " TEXT);";

    private String TAG = "SettingsDBHelper";

    public SettingsDBHelper(Context context, String name, CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public void createTable(String tableName) {
        String createTableSQL = "CREATE TABLE " + tableName + CREATE_TABLE_TEMPLATE;
        try {
            SQLiteDatabase db = this.getWritableDatabase();
            if (db != null) {
                db.execSQL(createTableSQL);
            }
        } catch (SQLiteException e) {
            Log.e(TAG, "Failed to create database tables " + tableName);
        }
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.v(TAG, "onCreate()");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
